package org.goyo.main.services.system.impl;

import java.util.List;

import javax.annotation.Resource;

import org.goyo.common.exception.DBException;
import org.goyo.common.exception.ServiceException;
import org.goyo.main.domain.dao.system.ISysResourceDao;
import org.goyo.main.domain.entity.system.SysResource;
import org.goyo.main.services.system.ISysResourceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class SysResourceServiceImpl implements ISysResourceService {

	@Resource
	private ISysResourceDao sysResourceDao;
	
	@Override
	public List<SysResource> getAllSysResource() throws DBException,
			ServiceException{
		List<SysResource> list = sysResourceDao.findByCond(null, null);
		return list;
	}

	@Override
	public String saveOrUpdateInfo(SysResource info) throws DBException,ServiceException {
		String uuid = null;
		if(info.getUuid() == null || "".equals(info.getUuid())){
			info.setUuid(null);
			uuid = sysResourceDao.save(info);
		}else{
			sysResourceDao.update(info);
			uuid = info.getUuid();
		}
		return uuid;
	}

	@Override
	public void delByUuids(String[] uuids) throws DBException, ServiceException {
		sysResourceDao.delBatch(SysResource.class, "uuid", uuids);
	}

}
